MsgBox "Error " & Format$(Err.Number) & _
" selecting printer." & vbCrLf & _
Err.Description
Exit Sub
End If
On Error GoTo 0
' Print to the newly selected Printer object. Printer.Print "Selected printer: " & Printer.DeviceName
Printer.EndDoc
End Sub
Unfortunately, the Common Dialog Control's printer selection capabilities vary greatly with different combinations of printer, device driver, operating system, and Visual Basic version. You may need to use some trial and error to determine which capabilities work for you.
Printer Properties
The Printer object has several attributes that you should understand to get the most out of your printer. Several of the most useful properties for controlling printer characteristics are listed below. The exact effects of many of these properties depend on your physical printer and the printer's device driver.
ColorMode. Determines whether a color printer prints in color or monochrome. ColorMode can have these values:
vbPRCMMonochrome. Output is printed in monochrome.
vbPRCMColor. Output is printed in color.
Copies. The number of copies to be printed. On many printers, it is faster to allow the printer to print multiple copies than to send the same output to the printer several times.
Duplex. For printers that can do two-sided printing, Duplex determines whether pages are printed on both sides. This property can have these values:
vbPRDPSimplex. Single-sided printing.
vbPRDPHorizontal. Double-sided printing with horizontal page turn.
vbPRDPVertical. Double-sided printing with vertical page turn.
FontCount. Returns the number of fonts available on the printer.
Fonts. Lists the fonts available on the printer.
Height. Sets the height of the paper. You can use Height and Width instead of one of the predefined values for PaperSize.
Orientation. Determines the paper orientation. Orientation can have the values:
vbPRORPortrait. The top of the page is along the short edge of the paper (normal).